package com.example.qianjun.gobang01.bean;

import android.graphics.Point;
import android.util.Log;

/**
 * Created by qianjun on 2016/5/2.
 */
public class GobangCheckboard {
    private int[][] table;
    private boolean isStop;
    private int totalStep;
    private int table_x;
    private int table_y;

    //存储悔棋队列
    private PreviousStep previousStep = new PreviousStep();

    public GobangCheckboard(int table_x, int table_y) {
        this.table_x = table_x;
        this.table_y = table_y;
        init();
    }

    public int getTable_x() {
        return table_x;
    }

    public void setTable_x(int table_x) {
        this.table_x = table_x;
    }

    public int getTable_y() {
        return table_y;
    }

    public void setTable_y(int table_y) {
        this.table_y = table_y;
    }

    public boolean isStop() {
        return isStop;
    }

    public void setStop(boolean stop) {
        isStop = stop;
    }

    public int[][] getTable() {
        return table;
    }

    public void setTable(int[][] table) {
        this.table = table;
    }

    public int getTotalStep() {
        return totalStep;
    }

    public void setTotalStep(int totalStep) {
        this.totalStep = totalStep;
    }

    public PreviousStep getPreviousStep() {
        return previousStep;
    }

    public void setPreviousStep(PreviousStep previousStep) {
        this.previousStep = previousStep;
    }

    /**
     * 初始化函数：
     * 悔棋队列初始化
     * 重置棋盘
     * 重置步数
     * 重置下棋状态
     */
    public void init() {
        previousStep.init();
        this.table = new int[table_x][table_y];
        this.totalStep = 0;
        this.isStop = false;
    }

    /**
     * 放置棋子
     *
     * @param point     棋子的位置
     * @param pieceType 是黑子还是白子
     */
    public void putChessPiece(Point point, int pieceType) {
        if (!isStop) {
            this.table[point.x][point.y] = pieceType;
            //将该棋子加入到悔棋队列
            previousStep.addOnePiece(point);
            this.totalStep++;
            //Log.i("mike", "-=-=-=" + totalStep);
        }


    }

}
